package org.maitaole.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.maitaole.entity.SysUser;
import org.maitaole.entity.TbCart;
import org.maitaole.mapper.SysUserMapper;
import org.maitaole.mapper.TbCartMapper;
import org.maitaole.service.ISysUserService;
import org.maitaole.service.ITbCartService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class TbCartServiceImpl implements ITbCartService {

    @Resource
    private TbCartMapper tbCartMapper;

    @Resource
    private ISysUserService iSysUserService;

    @Override
    public int insertSelective(TbCart record) {
        return tbCartMapper.insertSelective(record);
    }

    @Override
    public int insertTbCart(String fkCartUserName, Integer fkCartGoodId, Integer cartGoodPrice) {
        SysUser userByUsername = iSysUserService.findUserByUsername(fkCartUserName);
        System.out.println("userByUsername.getId() = " + userByUsername.getId());
        TbCart tbCart = new TbCart(null, userByUsername.getId(), fkCartGoodId, cartGoodPrice);
        return insertSelective(tbCart);
    }

    @Override
    public int selectLastPrimaryKey() {
        return tbCartMapper.selectLastPrimaryKey();
    }


}
